package tagdb.fragmentation;

import java.util.HashMap;

/**
 * This class holds all the masses used for the calculation of theoretical masses.
 *
 * @author Thilo Muth
 */
public class Masses extends HashMap<String, Double> {

    /**
     * Singleton Masses object.
     */
    private static Masses instance;
    
    // @TODO: Harald: most of the information in this class is already available in utilities...

    // The masses for all the amino acids including empty values for non-amino acid letters
    public static final double A = 71.037110;
    public static final double C = 103.009185;
    public static final double D = 115.026943;
    public static final double E = 129.042593;
    public static final double F = 147.068414;
    public static final double G = 57.021464;
    public static final double H = 137.058912;
    public static final double I = 113.084064;
    public static final double K = 128.094963;
    public static final double L = 113.084064;
    public static final double M = 131.040485;
    public static final double N = 114.042927;
    public static final double P = 97.052764;
    public static final double Q = 128.058578;
    public static final double R = 156.101111;
    public static final double S = 87.032028;
    public static final double T = 101.047679;
    public static final double V = 99.068414;
    public static final double W = 186.079313;
    public static final double Y = 163.06332;

    /**
     * The mass of Hydrogen
     */
    public static final double Hydrogen = 1.007825;
    /**
     * The mass of Carbon
     */
    public static final double Carbon = 12.000000;
    /**
     * The mass of Nitrogen
     */
    public static final double Nitrogen = 14.003070;
    /**
     * The mass of Oxygen
     */
    public static final double Oxygen = 15.994910;
    /**
     * The mass of an electron
     */
    public static final double Electron = 0.005490;
    /**
     * The mass of the C Terminus = Oxygen + 3 * Hydrogen
     */
    public static final double C_term = 19.017837;
    /**
     * The mass of the N Terminus = Hydrogen
     */
    public static final double N_term = 1.007825;

    /**
     * Private constructor for the singleton convention.
     */
    private Masses() {
        fillMap();
    }

    /**
     * Fill the masses map with key and values.
     */
    private void fillMap() {
        this.put("A", A);
        this.put("C", C);
        this.put("D", D);
        this.put("E", E);
        this.put("F", F);
        this.put("G", G);
        this.put("H", H);
        this.put("I", I);
        this.put("K", K);
        this.put("L", L);
        this.put("M", M);
        this.put("M+16", M + Oxygen);
        this.put("N", N);
        this.put("P", P);
        this.put("Q", Q);
        this.put("R", R);
        this.put("S", S);
        this.put("T", T);
        this.put("V", V);
        this.put("W", W);
        this.put("Y", Y);
        this.put("Hydrogen", Hydrogen);
        this.put("Carbon", Carbon);
        this.put("Nitrogen", Nitrogen);
        this.put("Oxygen", Oxygen);
        this.put("Electron", Electron);
        this.put("C_term", C_term);
        this.put("N_term", N_term);
    }

    /**
     * Returns the instance of a masses object.
     *
     * @return the instance of a masses object
     */
    public static Masses getInstance() {
        if (instance == null)
            instance = new Masses();
        return instance;
    }
}
